home *** CD-ROM | disk | FTP | other *** search
- Public Class TestPage
- Inherits System.Web.UI.Page
-
- ' the following region contains custom code that defines a pbar
- ' variable and initializes it to point to the PagingBar1 user control,
- ' so that the remainder of the code can reference that object
- ' as if it were a regular ASP.NET control
-
- #Region " Web Form Designer Generated Code "
-
- 'This call is required by the Web Form Designer.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
-
- End Sub
-
- Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
- 'CODEGEN: This method call is required by the Web Form Designer
- 'Do not modify it using the code editor.
- InitializeComponent()
- ' get a reference to the PagingBar1 user control
- pbar = DirectCast(FindControl("PagingBar1"), PagingBar)
- End Sub
- Protected WithEvents txtPages As System.Web.UI.WebControls.TextBox
- Protected WithEvents btnUpdate As System.Web.UI.WebControls.Button
- Protected WithEvents PlaceHolder1 As System.Web.UI.WebControls.PlaceHolder
- Protected WithEvents chkShowControl As System.Web.UI.WebControls.CheckBox
- Protected WithEvents lblPageData As System.Web.UI.WebControls.Label
- ' this variable retrieves a reference to the PaginBar control
- Protected WithEvents pbar As PagingBar
-
- #End Region
-
- Protected WithEvents pbar2 As PagingBar
-
- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- ' Initialize the page count the first time the page is shown
- If Not Me.IsPostBack Then
- pbar.PageCount = 50
- txtPages.Text = pbar.PageCount.ToString
- End If
-
- ' dinamically create a new PagingBar control if the checkbox
- ' is selected
- If chkShowControl.Checked Then
- pbar2 = DirectCast(LoadControl("PagingBar.ascx"), PagingBar)
- PlaceHolder1.Controls.Add(pbar2)
- pbar2.PageCount = 99
- End If
- End Sub
-
- ' handling event from the user control
-
- Private Sub pbar_PageChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles pbar.PageChanged
- lblPageData.Text = "( showing page #" & pbar.PageNumber & ")"
- End Sub
-
- ' enforce a different number of pages for the PagingBar control
-
- Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
- pbar.PageCount = CInt(txtPages.Text)
- End Sub
- End Class
-